perm filename STRUC.FAI[S,NET] blob sn#555541 filedate 1983-05-30 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	Structure definitions
C00004 00003	Field definition macros:
C00006 00004	Overlay Header Format (OV):
C00009 00005	Free Storage Block Format (FS):
C00015 ENDMK
C⊗;
SUBTTL Structure definitions

COMMENT ⊗

This file contains definitions of structures used.

Nodes are abbreviated by two letters, which are seen in this files
directory in parantheses. For example, a file header is FL.  Fields
consist of two letter type followed by an at most three letter field
name.  For example, CLNXT would be the NEXT field in a Circular List.
The offset of the field is defined as a half-killed symbol consisting
of the name of the field preceded by '%', so the offset for CLNXT
would be %CLNXT.  The size of the node in words is defined the node
name preceded by '%%', so the size of a circular list is %%CL.

Note: This file is also to be processed by another which extracts
text between αα's to generate STRUC.DOC

⊗;
	XALL		;Turn off macro expansion
;Field definition macros:
;
;The FIELD macro defines two other macros used to fetch and store
;particular field in a node.  The NAME arguent is the name to be
;used to fetch that field using the opcode, FETCH.  NAME with 'M'
;appended to it is used to store that field using the opcode,
;STORE. Finally, it defines %NAME as INDEX.
;
;Example:
;	FIELD Z,HRRE,HRRM,2
;Defines two macros, Z and ZM.  Example of the call of one is
;	ZM RET,FOO		;Store RET in the Z component of node
;				;pointed to by FOO.
;And expands to be
;	HRRM RET,2(FOO)
;
IFNMAC FIELD,<

DEFINE FIELD `(NAME,FETCH,STORE,INDEX,TYPE) <
DEFINE NAME(X,Y)<FETCH X,INDEX(Y)>
DEFINE NAME`M(X,Y)<STORE X,INDEX(Y)>
↓%`NAME←←INDEX
%%LAST←←INDEX>
 
;The BFIELD macro is like the FIELD macro except that it uses
;byte pointers. SIZE is the number of bits, and START is the
;bit number of the low order bit in the field.
DEFINE BFIELD `(NAME,SIZE,START,INDEX,TYPE) <
DEFINE NAME(X,Y)<LDB X,[POINT SIZE,INDEX(Y),START]>
DEFINE NAME`M(X,Y)<DPB X,[POINT SIZE,INDEX(Y),START]>
↓%`NAME←←INDEX
%%LAST←←INDEX>

;Define length of structure
DEFINE STRUCEND `(NAME) <
↓%%`NAME←←%%LAST+1
%%LAST←←0
>
>;IFNMAC FIELD
;Overlay Header Format (OV):

;Don't forget to change the prototype when changing this.
FIELD OVCUR,HRRZ,HRRM,0 	;Pointer to current buffer
FIELD OVFIR,HLRZ,HRLM,0 	;Pointer to first buffer
FIELD OVPTR,MOVE,MOVEM,1	;Byte pointer into buffer
FIELD OVCNT,MOVE,MOVEM,2	;Byte count left in buffer
FIELD OVNUM,HRRE,HRRM,3 	;Overlay number
FIELD OVCX,HLRE,HRLM,4		;Current X position
FIELD OVCY,HRRE,HRRM,4		;Current Y position
STRUCEND OV

;Overlay Buffer Format (OB):
FIELD OBSIZ,HRRZ,HRRM,0 	;Size (in words)
FIELD OBNXT,HLRZ,HRLM,0 	;Pointer to next buffer
STRUCEND OB

COMMENT αOverlay Header Format:

	 _____________________________________
	|		   |		      |
0:	|   First buffer   |  Current buffer  |
	|__________________|__________________|
	|		    		      |
1:	|  Byte pointer into current buffer   |
	|_____________________________________|
	|		    		      |
2:	|  Byte count left in current buffer  |
	|_____________________________________|
	|		   |		      |
3:	|     (Unused)	   |  Overlay number  |
	|__________________|__________________|
	|		   |		      |
4:	|    Current X     |    Current Y     |
	|__________________|__________________|



Overlay Buffer Format:

	 _____________________________________
	|		   |		      |
0:	|    Next buffer   |   -Buffer size   |
	|__________________|__________________|
	|		    		      |
	|		    		      |
	|		 Data		      |
	|		    		      |
	|		    		      |
	|_____________________________________|

α;
;Free Storage Block Format (FS):

;Don't change any of this without studying FS.FAI
FIELD FSGC,HRRZ,HRRM,-1 	;Garbage Collector's field (used block)
FIELD FSNXT,HRRZ,HRRM,-1	;Pointer to next free block
FIELD FSFSZ,HLRZ,HRLM,-1	;Size field for free block only
BFIELD FSSIZ,14,17,-1		;Size of block in general
BFIELD FSTAG,4,3,-1		;Tag field
FIELD FSPRV,HRRZ,HRRM,0 	;Pointer to previous free block
FIELD FSPSZ,HLRZ,HRLM,-2	;Pointer to previous block's size

;Bit definition
↓%FSMRK←←1B0		;Mark bit
↓%FSUSE←←1B1		;This block is in use
↓%FSPRA←←1B2		;Previous block is avaiable
↓%FSTMP←←1B3		;This block was allocated by expanding JOBFF

COMMENT αObject Header Format:

Free Block:
	 _____________________________________
	|    |		   |		      |
-1:	| 0  | Block size  |   Next pointer   |
	|____|_____________|__________________|
	|		   |		      |
	|     (Unused)	   | Previous pointer |
	|__________________|__________________|
	|		    		      |
	|		    		      |
	|	       N-2 Words	      |
	|		    		      |
	|_____________________________________|
	|		   |		      |
	|    -Block size   |	(unused)      |
	|__________________|__________________|

Used Table:
	 _____________________________________
	|Tag |		   |		      |
-1:	|Bits| Block Size  |   GC's field     |
	|____|_____________|__________________|
	|		    		      |
	|		    		      |
	|	        N Words 	      |
	|		    		      |
	|_____________________________________|

Tags bits:
400000,,0	Mark bit
200000,,0	This block is in use
100000,,0	Previous block is avaiable
040000,,0	This block was allocated by expanding JOBFF

α;
;End of structure definitions
	LALL		;Restore macro expansion